package com.wyu.ibm.security;

import com.wyu.ibm.entity.SystemUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * @author Leo
 */
@Component
public class SystemUserDetailsServiceImpl implements UserDetailsService {

    private Logger logger = LoggerFactory.getLogger(getClass());


    @Override
    public UserDetails loadUserByUsername(String userID) throws UsernameNotFoundException {
        SystemUser systemUser = new SystemUser();
        systemUser.setUserID("123");
        systemUser.setPassword("123");
        if(systemUser != null){
            return new SystemUserDetail(systemUser.getUserID(),systemUser.getPassword(), AuthorityUtils.commaSeparatedStringToAuthorityList("1"),systemUser);
        }
        logger.info("null");
        return null;
    }
}
